<template>
  <div class="content">
    <div class="box">
      <div class="arcbottom">
        <!-- <div class="settingCont" @click="setting">
          <van-icon name="setting-o" />
          <div class="settingTitle">设置</div>
        </div> -->
      </div>
    </div>
    <div class="center-white-style">
      <div class="grid-out-div">
        <van-grid :border="false" :center="true" :square="true" :clickable="true" :column-num="2">
            <van-grid-item class="gridItemFirst" :to="checkStockProcessing? '':inStorage">
                <div style="position: relative;">
                     <img
                       text="ABC"
                       :src="require('@/assets/ic_in_storage.png')"
                       height="80px"
                       width="80px"
                       badge="9"
                       v-show="!checkStockProcessing"
                     />
                     <img
                       text="ABC"
                       :src="require('@/assets/3.png')"
                       height="80px"
                       width="80px"
                       badge="9"
                       v-show="checkStockProcessing"
                     />
                     <div class="icons" v-show="inStockAmount !=0">{{inStockAmount}}</div>
                </div>
                <div style="margin-top: 20px" :class="checkStockProcessing?'fontCol':''">入库</div>
            </van-grid-item>
            <van-grid-item class="gridItemSecond" :to="checkStockProcessing? '':outStorage">
                <div style="position: relative;">
                     <img
                       text="ABC"
                       :src="require('@/assets/ic_out_storage.png')"
                       height="80px"
                       width="80px"
                       badge="9"
                       v-show="!checkStockProcessing"
                     />
                     <img
                       text="ABC"
                       :src="require('@/assets/1.png')"
                       height="80px"
                       width="80px"
                       badge="9"
                       v-show="checkStockProcessing"
                     />
                     <div class="icons" v-show="outStorageAmount !=0">{{outStorageAmount}}</div>
                </div>
                <div style="margin-top: 20px" :class="checkStockProcessing?'fontCol':''">出库</div>
            </van-grid-item>
            <van-grid-item class="gridItemThird" text="首页信息" :to="SeeStorageIndex">
                <div style="position: relative;">
                     <img
                       text="ABC"
                       :src="require('@/assets/ic_check_storage.png')"
                       height="80px"
                       width="80px"
                       badge="9"
                     />
                     <!-- <img
                       text="ABC"
                       :src="require('@/assets/2.png')"
                       height="80px"
                       width="80px"
                       badge="9"
                       v-show="checkStockAmount===0"
                     /> -->
                     <div class="icons" v-show="checkStockAmount !=0">{{checkStockAmount}}</div>
                </div>
                <p >盘库</p>
            </van-grid-item>
            <van-grid-item class="gridItemThird" text="首页信息" :to="settings">
                <div style="position: relative;">
                     <img
                       text="ABC"
                       :src="require('@/assets/ic_settings.png')"
                       height="80px"
                       width="80px"
                       badge="9"
                     />
                </div>
                <p>设置</p>
            </van-grid-item>
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { Grid, GridItem } from "vant";
import http from '@/utils/request.js';
import api from '@/utils/api.js';
import { mapState } from 'vuex'

Vue.use(Grid);
Vue.use(GridItem);

export default {
  data() {
    return {
      checkStockProcessing:'',
      inStockAmount:null,
      outStorageAmount:null,
      checkStockAmount:null,
      flag:false,
      inStorage:'/inStorage',
      outStorage:'/outStorage',
      SeeStorageIndex:'/SeeStorageIndex',
      settings:'/settings',
      MoveStore:'/MoveStore'
    };
  },
  created() {
    if(this.$store.state.user.roleCodes.indexOf('storageMovement') > -1){
        this.flag = true;
    }else{
        this.flag = false;
    }
    this.init()
  },
  methods: {
    init(){
        var params = {}
        http.fetchGet(api.getPADSchedule, params,'加载中...').then(res => {
            if(res.code === 1){
                this.inStockAmount = res.data.inStockAmount;
                this.outStorageAmount = res.data.outStorageAmount;
                this.checkStockAmount = res.data.checkStockAmount;
                this.checkStockProcessing = res.data.checkStockProcessing;
            }
        }).catch(err => {
            console.log(err)
        });
    },
    setting(){
      this.$router.push({
        path: "/settings",
      });
    }
  }
};
</script>
<style >
.content {
  display: flex;
  flex-direction: column;
  background: #f6f6f6;
  width: 100%;
  /* height: 100%; */
}

.box {
  width: 100%;
  height: 250px;
  text-align: center;
  position: absolute;
  background: #f6f6f6;
}

.center-white-style {
  position: relative;
  background: #fff;
  z-index: 1;
  margin-left: 30px;
  margin-right: 30px;
  margin-top: 60px;
  background: white;
  border-radius: 12px;
}
.grid-out-div {
  margin: 10px;
  background: white;
}

.arcbottom {
  border-bottom-left-radius: 60%;
  border-bottom-right-radius: 60%;

  background: #2e71ff;
  width: 100%;
  height: 150px;
}
.gridItemFirst {
  border-width: thin;
  border: 0.01px #EFEFEF;
  border-top-width: 0;
  border-style: solid;
  border-bottom-width: 0.01px;
  border-left-width: 0px;
  border-right-width: 0.01px;
}
.gridItemSecond {
    border-width: thin;
  border: 0.01px #EFEFEF;
  border-style: solid;
  border-top-width: 0;
  border-right-width: 0px;
  border-left-width: 0px;
}
.gridItemThird {
    border-width: thin;
  border: 0.01px #EFEFEF;
  border-top-width: 0;
  border-style: solid;
  border-left-width: 0px;
  border-bottom: 0px;
  border-right-width: 0.01px;
}
.gridItemFourth {
  border: none;
}

/* 图标 */
.icons {
  padding: 5px;
  right: 7px;
  top: 0;
  background: red;
  color: #fff;
  position: absolute;
  border-radius: 50%;
  width: 15px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fontCol{
  color: #C8C8C8;
}
.settingCont{
  position: absolute;
  top: 15px;
  right: 20px;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  font-size: 20px;
  cursor: pointer;
}
.settingTitle{
  margin-left: 5px;
  letter-spacing: 2px;
}
</style>
